<?php
date_default_timezone_set('UTC');
//1.连接数据库
$link = @mysql_connect('localhost','root','root');
//2.判断连接是否成功
if(!$link){
	die('连接失败');
}
//3.选择数据库
mysql_select_db('team4');
//4.设置字符集
mysql_set_charset('utf8');
//5.准备sql语句
$sql = 'select * from liuyan';
//6.发送sql语句
$res = mysql_query($sql);
//7.处理结果集
$arr = array();
echo '<table border="1">';
echo '<tr>';
echo '<th>编号</th>';
echo '<th>标题</th>';
echo '<th>作者</th>';
echo '<th>内容</th>';
echo '<th>发布时间</th>';
echo '<th>操作</th>';
echo '</tr>';
while($row = mysql_fetch_assoc($res)){
	echo '<tr>';
	echo '<td>'.$row['id'].'</td>';
	echo '<td>'.$row['title'].'</td>';
	echo '<td>'.$row['author'].'</td>';
	echo '<td>'.mb_substr($row['content'],0,20,'utf-8').'</td>';
	echo '<td>'.date('Y-m-d H:i:s',$row['addtime']).'</td>';
	echo '<td><a href="delete.php?id='.$row['id'].'">删除</a>/<a href="update.php?id='.$row['id'].'">编辑</a></td>';
	echo '</tr>';
}
echo '</table>';
//8.释放资源并且关闭数据库
mysql_free_result($res);
mysql_close();
?>
<a href="insert.php">添加</a>